package com.railway.dao.impl;

import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import com.railway.bean.Ticket;
import com.railway.dao.TicketDao;
import com.railway.util.DBUtil;

public class TicketDaoImpl implements TicketDao {

	JdbcTemplate jt = new JdbcTemplate(DBUtil.getDataSource());
	
	@Override
	public int deleteTicket(int ticket_id) {
		String sql = "update ticket set is_quit = 1 where ticket_id = ?";
		return jt.update(sql,ticket_id);
	}

	@Override
	public List<Ticket> selectTicket(int train_id) {
		String sql = "select * from ticket where train_id = ?";
		return jt.query(sql, new BeanPropertyRowMapper<Ticket>(Ticket.class), train_id);
	}

}
